﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ObligatorioBD.MerObjects
{
    public class Entity : IAtributeObject, IObjectId
    {
        String name;
        int id = -1;
        List<Atribute> atributes;
        bool isWeak;
        public Entity(string name, bool isWeak = false)
        {
            this.name = name;
            this.atributes = new List<Atribute>();
            this.isWeak = isWeak;
        }
        public void AddAtribute(Atribute atribute)
        {
            this.atributes.Add(atribute);             
        }
        public void RemoveAtribute(Atribute atribute) 
        {
            this.atributes.Remove(atribute);
        }
        public bool IsWeak
        {
            get { return this.isWeak; }
        }
        public string Name
        {
            get { return this.name; }
        }
        public List<Atribute> Atributes
        {
            get { return this.atributes; }
        }
        public int ObjectId
        {
            get { return this.id; }
            set { this.id = value; }
        }
        public List<Atribute> GetAtributes()
        {
            return this.atributes;
        }
        public bool Contains(string atributeName)
        {
            bool contains = false;
            foreach (Atribute a in this.atributes)
            {
                if (a.Name == atributeName)
                {
                    contains = true;
                }
            }
            return contains;
        }
    }
}
